#pragma once
#include <iostream>
#include <string>

class Task
{
public:
    Task() = default;

    Task(int x, int y, char opt) : _x(x), _y(y), _opt(opt), _ret(0), _exit_code(0)
    {
    }

    std::string equation()
    {
        return std::to_string(_x) + _opt + std::to_string(_y) + '=';
    }

    int getResult() const
    {
        return _ret;
    }

    void operator()()
    {
        switch (_opt)
        {
        case '+':
            _ret = _x + _y;
            break;
        case '-':
            _ret = _x - _y;
            break;
        case '*':
            _ret = _x * _y;
            break;
        case '/':
        {
            if (_y != 0)
                _ret = _x / _y;
            else
                _exit_code = -1;
        }
        break;
        case '%':
        {
            if (_y != 0)
                _ret = _x % _y;
            else
                _exit_code = -1;
        }
        break;
        default:
            break;
        }
    }

private:
    int _x;
    int _y;
    char _opt;
    int _ret;
    int _exit_code;
};